import Vue from 'vue'
import store from '@/store'

// confirm
Vue.prototype.$confirm = function (opt) {
  store.state.confirm.visible = true
  store.state.confirm.option = opt
}

Vue.prototype.$tips = function (text, time = 3000) {
  if (document.querySelector('.apptips')) {
    document.querySelector('.apptips').remove()
  }
  const tip = document.createElement('div')
  tip.className = 'apptips'
  tip.innerText = text
  document.body.appendChild(tip)
  setTimeout(() => {
    tip.className += ' ' + 'apptips__show'
  }, 150)
  setTimeout(() => {
    tip.remove()
  }, time)
}
